<template>
    <a-drawer
    width="300"
    placement="right"
    :closable="false"
    :visible="visible">
    <div class="setting-drawer-index-content">
        <div :style="{ marginBottom: '24px' }">
          <h3 class="setting-drawer-index-title">整体风格设置</h3>
          <div class="setting-drawer-index-blockChecbox">
            <a-tooltip>
              <template #title>亮色菜单风格</template>
              <div class="setting-drawer-index-item" @click="handleStyleColor('light')">
                <svg-icon iconClass="style-white" className="style-white_icon" size="45px" />
                <div class="setting-drawer-index-selectIcon" v-if="getStyleColor() === 'light'">
                  <CheckOutlined/>
                </div>
              </div>
            </a-tooltip>
            <a-tooltip>
              <template #title>暗色菜单风格</template>
              <div class="setting-drawer-index-item" @click="handleStyleColor('dark')">
                <svg-icon iconClass="style-black" className="style-black_icon" size="45px" />
                <div class="setting-drawer-index-selectIcon" v-if="getStyleColor() !== 'light'">
                  <CheckOutlined/>
                </div>
              </div>
            </a-tooltip>
          </div>
        </div>
        <div :style="{ marginBottom: '24px' }">
          <h3 class="setting-drawer-index-title">主题色</h3>
          <div style="height: 20px">
            <a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in getTheme()" :key="index">
              <template #title>
                {{ item.color }}
              </template>
              <a-tag :color="item.color" @click="changeColor(index)">
                <CheckOutlined v-if="getThemeColor()===index"/>
              </a-tag>
            </a-tooltip>
          </div>
        </div>
        <div :style="{ marginBottom: '24px' }">
          <h3 class="setting-drawer-index-title">导航模式</h3>

          <div class="setting-drawer-index-blockChecbox">
            <a-tooltip>
              <template #title>侧边栏导航</template>
              <div class="setting-drawer-index-item" @click="handleLayout('sidemenu')">
                <svg-icon iconClass="sidemenu" className="sidemenu_icon" size="45px" />
                <div class="setting-drawer-index-selectIcon" v-if="getLayoutMode() === 'sidemenu'">
                  <CheckOutlined/>
                </div>
              </div>
            </a-tooltip>

            <a-tooltip>
              <template #title>顶部栏导航</template>
              <div class="setting-drawer-index-item" @click="handleLayout('topmenu')">
                <svg-icon iconClass="topmenu" className="topmenu" size="45px" />
                <div class="setting-drawer-index-selectIcon" v-if="getLayoutMode() === 'topmenu'">
                  <CheckOutlined/>
                </div>
              </div>
            </a-tooltip>

            <a-tooltip>
              <template #title>混合布局</template>
              <div class="setting-drawer-index-item" @click="handleLayout('blendmenu')">
                <svg-icon iconClass="topmenu" className="topmenu_icon" size="45px" />
                <div class="setting-drawer-index-selectIcon" v-if="getLayoutMode() === 'blendmenu'">
                  <CheckOutlined/>
                </div>
              </div>
            </a-tooltip>
          </div>
        </div>
      </div>

    <template v-slot:handle>
      <div class="setting-drawer-index-handle" @click="toggle">
        <SettingOutlined v-if="!visible"/>
        <CloseOutlined type="copied" v-else/>
      </div>
    </template>
  </a-drawer>
  
</template>
<script lang="ts">
import { Options, Vue } from 'vue-class-component';
import {
  SettingOutlined,CloseOutlined,CheckOutlined
} from '@ant-design/icons-vue';
import ThemeConfig from '@/config/ThemeConfig';
import ITheme from '@/api/entity/ITheme';
import themeColor from '../commonbase/themeColor';
const less = require('less')

@Options({
  components: {
    SettingOutlined,CloseOutlined,CheckOutlined
  },
})
export default class SettingDrawer extends Vue {
    private placement:String = 'right';
    private visible:boolean = false;

    public getTheme():Array<ITheme>{
      return new ThemeConfig().getTheme();
    }

    public getStyleColor():string{
      return (this as any).$store.getters.styleColor;
    }

    public getThemeColor():string{
      return (this as any).$store.getters.themeIndex;
    }

    public handleStyleColor (theme:string) :void {
      (this as any).$store.dispatch('styleColor', theme);
    }

    public getLayoutMode():String{
        return (this as any).$store.getters.layoutMode;
    }

    public handleLayout(mode:number): void {
        (this as any).$store.dispatch("layoutMode" , mode);
    }

    public toggle () :void {
      this.visible = !this.visible
    }

    public changeColor(index:number):void{
      new themeColor().changeAttrColr(index);
    }
}
</script>
<style lang="less">
.setting-drawer-index-handle {
    position: absolute;
    top: 50%;
    width: 48px;
    height: 48px;
    margin-top: -48px;
    right: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 1001;
    text-align: center;
    font-size: 16px;
    border-radius: 4px 0 0 4px;
  
    svg {
      color: rgb(255, 255, 255);
      font-size: 20px;
    }
  }
.ant-drawer-content {
    overflow: visible;
}
.ant-drawer-wrapper-body {
    overflow: visible;
}
.setting-drawer-index-content {
  .setting-drawer-index-blockChecbox {
    display: flex;
    .setting-drawer-index-item{
      margin-right: 16px;
      position: relative;
      border-radius: 4px;
      cursor: pointer;
      img {
        width: 48px;
      }
      .setting-drawer-index-selectIcon {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        padding-top: 15px;
        padding-left: 24px;
        height: 100%;
        color: #1890ff;
        font-size: 14px;
        font-weight: 700;
      }
    }
  }
  .setting-drawer-theme-color-colorBlock {
    width: 20px;
    height: 20px;
    border-radius: 2px;
    float: left;
    cursor: pointer;
    margin-right: 8px;
    padding-left: 0px;
    padding-right: 0px;
    text-align: center;
    color: #fff;
    font-weight: 700;

    svg {
      font-size: 14px;
      color: #fff;
    }
  }
}
</style>